package edu.hhu.controller;

import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletResponse;

import com.alibaba.fastjson.JSON;
import com.jfinal.core.Controller;
import com.jfinal.plugin.activerecord.Db;
import com.jfinal.plugin.activerecord.Record;

import edu.hhu.model.User;
import tree.TreeService;
public class LoginController extends Controller{
	public void index(){
		this.render("/userpage/login.jsp");
	}
	public void indexPage(){
		String username = this.getPara("name");
		String password = this.getPara("password");
		//List<User> list = User.dao.find("select * from user where username='"+username+"'and password='"+password+"'");
		String[] para = new String[]{username,password};
		List<User> list = User.dao.find("select * from user where username=? and password=?",para);

		if(!list.isEmpty()){
		/*this.setAttr("name", username);
		this.setAttr("password", password);*/
			
//		String sql="select a.wellgroupcode wellgroupcode,SUM(IFNULL(a.YLCQ,0))as 月累产气量,SUM(IFNULL(a.LLCQ,0))as 年累产气量,SUM(IFNULL(a.LJCQ,0))as 累产气量,SUM(IFNULL(a.YLCY,0))as 月累产液量,SUM(IFNULL(a.LLCY,0))as 年累产液量,SUM(IFNULL(a.LJCY,0))as 累产液量 from (SELECT  cjkj.wellame,cjkj.wellgroupcode,cjkj.wellcode,cjkj.blockcode,cjkj.gasfieldcode, cjsctjtemp.LJCQ,cjsctjtemp.LJCY ,cjsctjtemp.LLCQ,cjsctjtemp.LLCY,cjsctjtemp.YLCQ,cjsctjtemp.YLCY from cjsctjtemp INNER JOIN cjkj ON cjsctjtemp.wellcode=cjkj.wellcode AND cjkj.wellgroupcode!=' ')a GROUP BY a.wellgroupcode";
//		List<Record> data = Db.use("mysql").find(sql);
//		List<Map<String, Object>> dataList = new ArrayList<Map<String, Object>>();
//		for (int i = 0; i < data.size(); i++) {
//			dataList.add(data.get(i).getColumns());
//		}
//		this.setAttr("data", dataList);	
		this.redirect("/home/index.jsp");
		}else{
			this.render("/userpage/login.jsp");
		}
	}
	 public void summery(){
		 this.render("/home/index.jsp");
	 }
	 
	 
}
